package com.hubiao.pro.service.impl;

import com.hubiao.pro.common.constant.Constants;
import com.hubiao.pro.domain.db.User;
import com.hubiao.pro.service.RabbitMqService;
import com.hubiao.pro.service.mq.DataCenterProducerMq;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Description
 *
 * @author hubiao
 * @since 2021-01-30 22:31
 */
@Service
public class RabbitMqServiceImpl implements RabbitMqService {

    @Resource
    private DataCenterProducerMq dataCenterProducerMq;

    /**
     * 测试消息堆积方案
     */
    @Override
    public void sendUserAll() {
        for (int i = 0; i < 2000; i++) {
            User user = new User();
            user.setUserId( i + "" );
            user.setUserName( "胡彪_" + i );
            user.setAge( i );
            dataCenterProducerMq.send( user, Constants.MONITOR_EXCHANGE_TEST, Constants.MONITOR_ROUTINGKEY_TEST );
        }
    }
}
